<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>专家评分</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript"
            charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .mbox {
        padding: 8px
    }

    .item img {
        height: 40px;
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .information {
        background: #e8f4fc;
        height: 30px;
        line-height: 30px;
    }

    .add {
        height: 30px;
    }

    .layui-form-item {
        margin-bottom: 5px;
    }

    .layui-input-inline {
        width: 300px !important;
    }

    .openFile input[type=file] {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 18px;
        z-index: 99;
        opacity: 0;
    }

    .btn .layui-btn {
        margin-left: 10px;
    }

    .typeIpt {
        line-height: 30px;
        margin-left: 10px;
    }

    .layui-table-tool {
        display: none;
    }

</style>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">专家评分</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <span class="typeIpt layui-form">
            <input type="radio" checked lay-filter="status" value="1" name="status" title="未开始"/>&nbsp;
            <input type="radio" lay-filter="status" value="2" name="status" title="评审中"/>&nbsp;
            <input type="radio" lay-filter="status" value="3" name="status" title="评审结束"/>&nbsp;
        </span>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
</body>
</html>
<%--<script type="text/html" id="barDemo">--%>
    <%--<a class="layui-btn layui-btn-xs" lay-event="operate">评审</a>--%>
<%--</script>--%>
<script type="text/html" id="barDemo">
    {{#  if(d.reviewStatus == 1){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="operate">评审</a>
    {{#  } }}
    {{#  if(d.reviewStatus == 2){ }}
    <a class="layui-btn layui-btn-xs" lay-event="approve">评分</a>
    {{#  } }}
<%--
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="noapprove">不批准</a>
--%>
</script>
<%--<script type="text/html" id="barDemo">--%>

    <%--{{# if (d.examType ==0){ }}--%>
    <%--<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="operate">评审</a>--%>
    <%--{{#  } else if(d.examType ==1){ }}--%>
    <%--<a class="layui-btn layui-btn-xs" lay-event="operate">批准</a>--%>
    <%--{{#  } else if(d.examType ==2){ }}--%>
    <%--<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="operate">不批准</a>--%>
<%--</script>--%>
<script>
    layui.use(['table', 'form', 'laydate', 'upload'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload;
        form.render()
        var tableData=table.render({
            elem: '#test'
            , url: '/rpmTopic/selectTopicR'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['']
            , title: '用户数据表'
            , where:{
                status:1
            }
            , cols: [[{field: 'epnumSub', title: '专家人数'}
                , {field: 'epStartTime', title: '专家评分开始日期'}
                , {field: 'epEndTime', title: '专家评结束日期'}
                , {field: 'reviewStatus', title: '评审状态', templet: function (d) {
                        if (d.reviewStatus == 1) {
                            return '未开始'
                        } else if (d.reviewStatus == 2) {
                            return '评审中'
                        } else {
                            return '评审结束'
                        }
                    }}
                , {field: 'reviewFraction', title: '评分分数'}
                , {field: 'scoreRule', title: '评分规则'}
                , {field: 'type', title: '操作', toolbar: '#barDemo'}
            ]]
            , page: true
            , parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "data": res.object.rpmTopics,//解析数据列表
                };
            }
        });
        form.on('radio(status)', function (data) {
            tableData.reload({
                where:{
                    status:data.value
                }
            })
        });
        $.ajax({
            url: '/Meetequipment/getuser',
            type: 'get',
            dataType: 'json',
            success: function (res) {
                $('table').attr('id',res.object.userId)
            }
        })


        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            var text=$(this).text();
            if(obj.event === 'operate'){

                layer.confirm('确定开始评审?', {icon: 3, title:'提示'}, function(index){
                    $.ajax({
                        type: 'get',
                        url: '/rpmTopic/update',
                        data: 'reviewStatus='+'2'
                            +'&planId='+ obj.data.planId
                            +'&userId='+$('table').attr('id'),
                        dataType: 'json',
                        success: function (res) {
                            if (res.flag) {
                                layer.msg('操作成功！', {icon: 1});
                                tableData.reload()
                                layer.closeAll();
                            }
                        }
                    })
                    layer.close(index);
                });

                // layer.open({
                //     type: 1,
                //     title:'审核',
                //     btn: ['确定', '取消'],
                //     shade: 0.5,
                //     maxmin: true, //开启最大化最小化按钮
                //     area: ['20%', '20%'],
                //     // content:"是否确定审核",
                //     content:'<div>\n' +
                //             '<p style="text-align: center;line-height: 20%">是否确定审核</p>\n'+
                //         '</div>',
                //     success:function (res) {
                //         //日期
                //         laydate.render({
                //             elem: '#date'
                //             ,type: 'datetime'
                //             ,value: new Date(),
                //         });
                //         $('.choice').click(function () {
                //             user_id = $(this).siblings('input').attr('id');
                //             $.popWindow("../common/selectUser?0");
                //         });
                //         $('.empty').click(function () {
                //             $(this).siblings('input').val('').attr('user_Id', '')
                //         })
                //         form.render();
                //     },
                //     yes:function (index) {
                //         var directorLeaderStatus=''
                //         if(text=='批准'){
                //             directorLeaderStatus=1
                //         }else{
                //             directorLeaderStatus=2
                //         }
                //         $.ajax({
                //             url: '/rpmTopic/update',
                //             dataType: 'json',
                //             type: 'get',
                //             data: 'reviewStatus='+'2'
                //             +'&planId='+ obj.data.planId
                //             +'&userId='+$('table').attr('id'),
                //            /* data:$('#ajaxforms').serialize()
                //                 +'&planId='+ obj.data.planId
                //                 +'&userId='+$('table').attr('id')
                //                 +'&directorLeaderStatus='+directorLeaderStatus
                //                 +'&directorLeader='+$('#directorLeader').attr('user_Id').split(',')[0],*/
                //             success: function (res) {
                //                 if (res.flag) {
                //                     layer.msg('操作成功！', {icon: 1});
                //                     tableData.reload()
                //                     layer.closeAll();
                //                 }
                //             }
                //         })
                //     }
                // })
            }else if(obj.event==='approve'){
                layer.open({
                    type: 1,
                    title:'批准',
                    btn: ['确定', '取消'],
                    shade: 0.5,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['40%', '50%'],
                    content: '<div id="conts" style="margin: 10px">\n' +
                        '        <form class="layui-form" action="" id="forms" lay-filter="forms">\n' +
                        '  <div class="layui-inline">\n' +
                        '      <label class="layui-form-label" style=" width: 113px;">专家人数</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input type="text" name="epnumSub" lay-verify="required|number" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>'+
                       '  <div class="layui-inline"  style="margin-top:20px;margin-bottom: 20px">\n' +
                        '      <label class="layui-form-label" style=" width: 113px;">专家评分开始日期</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input type="text" name="epStartTime" id="date" lay-verify="required|number" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>'+
                        '  <div class="layui-inline">\n' +
                        '      <label class="layui-form-label" style=" width: 113px;">专家评分结束日期</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input type="text" name="epEndTime" id="date1" lay-verify="required|number" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>'+
                        '  <div class="layui-inline" style="margin-top: 20px">\n' +
                        '      <label class="layui-form-label" style=" width: 113px;">评分分数</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input type="text" name="reviewFraction" lay-verify="required|number" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>'+
                        '  <div class="layui-inline" style="margin-top:20px">\n' +
                        '      <label class="layui-form-label" style=" width: 113px;">评分规则</label>\n' +
                        '      <div class="layui-input-inline">\n' +
                        '        <input type="text" name="scoreRule" lay-verify="required|number" autocomplete="off" class="layui-input">\n' +
                        '      </div>\n' +
                        '    </div>'+
                        '        </form>\n' +
                        '    </div>',
                    success:function (res) {
                        //日期
                        laydate.render({
                            elem: '#date'
                            // ,value: new Date(),获取当前时间
                        });
                        //日期
                        laydate.render({
                            elem: '#date1'
                            // ,value: new Date(),
                        });
                        form.render();
                    },
                    yes:function (index) {
                        $.ajax({
                            url: '/rpmTopic/update',
                            dataType: 'json',
                            type: 'get',
                            data:$('#forms').serialize()
                                +'&reviewStatus='+"3"
                                +'&planId='+ obj.data.planId
                                +'&userId='+$('table').attr('id'),
                            success: function (res) {
                                if (res.flag) {
                                    layer.msg('操作成功！', {icon: 1});
                                    tableData.reload()
                                    layer.closeAll();
                                }
                            }
                        })
                    }
                })
            }else{
                $.ajax({
                    url: '/rpmTopic/insetCertificate',
                    dataType: 'json',
                    type: 'get',
                    data:{directorLeaderStatus:3,planId:obj.data.planId},
                    success: function (res) {
                        if (res.flag) {
                            layer.msg('操作成功！', {icon: 1});
                            tableData.reload()
                            layer.closeAll();
                        }
                    }
                })
            }
        });
    });
</script>
